#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>

typedef int DataType;
typedef struct node
{
	DataType data;
	struct node* next;
}ListNode, *LinkList;

LinkList CreatList(DataType arr[], int len)
{
	LinkList head, p, q;
	int i = 0;
	p = head = (LinkList)malloc(sizeof(ListNode));
	while (i < len)
	{
		q = (LinkList)malloc(sizeof(ListNode));
		q->data = arr[i];
		p->next = q;
		p = q;
		i++;
	}
	p->next = NULL;
	return head;
}



void printflist(LinkList head)
{
	LinkList p = head->next;
	while (p)
	{
		printf("%5d", p->data);
		p = p->next;
	}
	printf("\n");
}



void Reverse(LinkList head)
{
	LinkList s, p;
	s = head->next;
	head->next = NULL;
	while (s)
	{
		p = s->next;
		s->next = head->next;
		head->next = s;
		s = p;
	}
}


int main()
{
	DataType arr[] = { 1,2,3,4,5,6 };
	int len = sizeof(arr) / sizeof(arr[0]);
	LinkList h = CreatList(arr, len);
	printflist(h);
	Reverse(h);
	printflist(h);
	return 0;
}








